package com.jframework.module.usps;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import com.jframework.module.usps.Services.USPSIntlRateService;
import com.jframework.module.usps.Services.USPSRateV3Service;
import com.jframework.module.usps.Services.USPSService;

/**
 * 
 * @author AJain
 *
 */
public class USPSServiceFactory 
{
    static Log log = LogFactory.getLog(USPSServiceFactory.class);
    
   // protected BeanXMLMapping xmlMapping = null;
    
  public USPSService getUSPSService(String apiName, String uspsURL, String dtdResourceURL) 
  throws Exception
  {
	if (null != apiName)
	{
	  USPSService service = null;

	  if (apiName.equalsIgnoreCase(USPSConstants.API_TYPE_RateV3))
	    service = new USPSRateV3Service();	   
	  
	  else if (apiName.equalsIgnoreCase(USPSConstants.API_TYPE_IntlRate))
	    service = new USPSIntlRateService();
	  
	  else
		  throw new Exception("Invalid USPS API Name, API Name : "+apiName);
	  
      service.setAPIName(apiName);
	  service.initialize(uspsURL, dtdResourceURL);
      return service;
	}
	
	return null;
  }

}
